package controller

import (
	"go-react-microservice/models"
)

type menuController struct{}

//CreateMenu 创建目录
func (controller *menuController) CreateMenu(model *models.Menu) (int, error) {
	result := models.MysqlDB.Create(model)
	return int(result.RowsAffected), result.Error
}

func (controller *menuController) GetMenuList() []models.Menu {
	var menu []models.Menu
	models.MysqlDB.Find(&menu)
	return menu
}

func (controller *menuController) GetInfo(id int) models.Menu {
	var menu models.Menu
	models.MysqlDB.Where("id=?", id).First(&menu)
	return menu
}

var MenuController menuController
